#define _CRT_SECURE_NO_WARNINGS 1
public:
    bool judge(TreeNode* root) {
        if (root == nullptr)
            return true;
        if (root->val == 1)
            return false;
        return judge(root->left) && judge(root->right);
    }
    TreeNode* pruneTree(TreeNode* root) {
        if (judge(root))
            return nullptr;
        if (root->left)
            root->left = pruneTree(root->left);
        if (root->right)
            root->right = pruneTree(root->right);
        return root;
    }
};